home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Mail / pine3.92 / pine / osdep / dosextra < prev    next >
Text File  |  1996-03-14  |  34KB  |  993 lines

  1. #line 2 "osdep/dosextra"
  2.  
  3. /*----------------------------------------------------------------------
  4.     Translation tables to map DOS codepages to ISO-8859-1 charsets and
  5.     back.
  6.  
  7.  Note: These tables were basically lifted from Kermit 3.11 and
  8.        the textps.c program also distributed from Columbia U.
  9.   ----------------------------------------------------------------------*/
  10. #ifndef _WINDOWS
  11. /*
  12.  * Map from ISO 8859-1 Latin-1 to Code Page 437
  13.  */
  14. unsigned char L1cp437[] = {
  15.   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,
  16.  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,
  17.  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,  45,  46,  47,
  18.  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,  60,  61,  62,  63,
  19.  64,  65,  66,  67,  68,  69,  70,  71,  72,  73,  74,  75,  76,  77,  78,  79,
  20.  80,  81,  82,  83,  84,  85,  86,  87,  88,  89,  90,  91,  92,  93,  94,  95,
  21.  96,  97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
  22. 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
  23. 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
  24. 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
  25.  32, 173, 155, 156,  15, 157, 124,  21,  34,  64, 166, 174, 170, 196,  63,  45,
  26. 248, 241, 253,  51,  39, 230,  20, 250,  44,  49, 167, 175, 172, 171,  63, 168,
  27.  65,  65,  65,  65, 142, 143, 146, 128,  69, 144,  69,  69,  73,  73,  73,  73,
  28.  68, 165,  79,  79,  79,  79, 153,  88,  79,  85,  85,  85, 154,  89,  63, 225,
  29. 133, 160, 131,  97, 132, 134, 145, 135, 138, 130, 136, 137, 141, 161, 140, 139,
  30.  63, 164, 149, 162, 147, 111, 148, 246, 111, 151, 163, 150, 129, 121,  63, 152
  31. };
  32.  
  33.  
  34. /*
  35.  * Map from ISO 8859-1 Latin-1 to Code Page 850
  36.  */
  37. unsigned char L1cp850[] = {
  38.   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,
  39.  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,
  40.  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,  45,  46,  47,
  41.  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,  60,  61,  62,  63,
  42.  64,  65,  66,  67,  68,  69,  70,  71,  72,  73,  74,  75,  76,  77,  78,  79,
  43.  80,  81,  82,  83,  84,  85,  86,  87,  88,  89,  90,  91,  92,  93,  94,  95,
  44.  96,  97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
  45. 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
  46. 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
  47. 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
  48.  32, 173, 189, 156, 207, 190, 221, 245, 249, 184, 166, 174, 170, 240, 169, 238,
  49. 248, 241, 253, 252, 239, 230, 244, 250, 247, 251, 167, 175, 172, 171, 243, 168,
  50. 183, 181, 182, 199, 142, 143, 146, 128, 212, 144, 210, 211, 222, 214, 215, 216,
  51. 209, 165, 227, 224, 226, 229, 153, 158, 157, 235, 233, 234, 154, 237, 232, 225,
  52. 133, 160, 131, 198, 132, 134, 145, 135, 138, 130, 136, 137, 141, 161, 140, 139,
  53. 208, 164, 149, 162, 147, 228, 148, 246, 155, 151, 163, 150, 129, 236, 231, 152
  54. };
  55.  
  56.  
  57. /*
  58.  * Map from ISO 8859-1 Latin-1 to Code Page 860
  59.  */
  60. unsigned char L1cp860[] = {
  61.   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,
  62.  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,
  63.  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,  45,  46,  47,
  64.  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,  60,  61,  62,  63,
  65.  64,  65,  66,  67,  68,  69,  70,  71,  72,  73,  74,  75,  76,  77,  78,  79,
  66.  80,  81,  82,  83,  84,  85,  86,  87,  88,  89,  90,  91,  92,  93,  94,  95,
  67.  96,  97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
  68. 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
  69. 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
  70. 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
  71.  32, 173, 155, 156,  15,  89, 124,  21,  34,  64, 166, 174, 170, 196,  63,  45,
  72. 248, 241, 253,  51,  39, 230,  20, 250,  44,  49, 167, 175, 172, 171,  63, 168,
  73. 145, 134, 143, 142,  65,  65,  65, 128, 146, 144, 137,  69, 139, 152,  73,  73,
  74.  68, 165, 169, 159, 140, 153,  79,  88,  79, 157, 150,  85, 154,  89,  63, 225,
  75. 133, 160, 131, 132,  97,  97,  97, 135, 138, 130, 136, 101, 141, 161, 105, 105,
  76.  63, 164, 149, 162, 147, 148, 111, 246, 111, 151, 163, 117, 129, 121,  63, 121
  77. };
  78.  
  79.  
  80. /*
  81.  * Map from ISO 8859-1 Latin-1 to Code Page 863
  82.  */
  83. unsigned char L1cp863[] = {
  84.   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,
  85.  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,
  86.  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,  45,  46,  47,
  87.  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,  60,  61,  62,  63,
  88.  64,  65,  66,  67,  68,  69,  70,  71,  72,  73,  74,  75,  76,  77,  78,  79,
  89.  80,  81,  82,  83,  84,  85,  86,  87,  88,  89,  90,  91,  92,  93,  94,  95,
  90.  96,  97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
  91. 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
  92. 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
  93. 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
  94.  32,  63, 155, 156, 152,  89, 160, 143, 164,  64,  97, 174, 170, 196,  63, 167,
  95. 248, 241, 253, 166, 161, 230, 134, 250, 165,  49, 111, 175, 172, 171, 173,  63,
  96. 142,  65, 132,  65,  65,  65,  65, 128, 145, 144, 146, 148,  73,  73, 168, 149,
  97.  68,  78,  79,  79, 153,  79,  79,  88,  79, 157,  85, 158, 154,  89,  63, 225,
  98. 133,  97, 131,  97,  97,  97,  97, 135, 138, 130, 136, 137, 105, 105, 140, 139,
  99.  63, 110, 111, 162, 147, 111, 111, 246, 111, 151, 163, 150, 129, 121,  63, 121
  100. };
  101.  
  102.  
  103. /*
  104.  * Map from ISO 8859-1 Latin-1 to Code Page 865
  105.  */
  106. unsigned char L1cp865[] = {
  107.   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,
  108.  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,
  109.  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,  45,  46,  47,
  110.  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,  60,  61,  62,  63,
  111.  64,  65,  66,  67,  68,  69,  70,  71,  72,  73,  74,  75,  76,  77,  78,  79,
  112.  80,  81,  82,  83,  84,  85,  86,  87,  88,  89,  90,  91,  92,  93,  94,  95,
  113.  96,  97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
  114. 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
  115. 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
  116. 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
  117.  32, 173,  63, 156, 175,  89, 124,  21,  34,  64, 166, 174, 170, 196,  63, 196,
  118. 248, 241, 253,  51,  39, 230,  20, 250,  44,  49, 167,  63, 172, 171,  63, 168,
  119.  65,  65,  65,  65, 142, 143, 146, 128,  69, 144,  69,  69,  73,  73,  73,  73,
  120.  68, 165,  79,  79,  79,  79, 153,  88, 157,  85,  85,  85, 154,  89,  63, 225,
  121. 133, 160, 131,  97, 132, 134, 145, 135, 138, 130, 136, 137, 141, 161, 140, 139,
  122.  63, 164, 149, 162, 147, 111, 148, 246, 155, 151, 163, 150, 129, 121,  63, 152
  123. };
  124.  
  125.  
  126. /*
  127.  * Map from ISO 8859-5 Latin-1 to Code Page 866
  128.  */
  129. unsigned char L5cp866[] = {
  130.   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,
  131.  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,
  132.  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,  45,  46,  47,
  133.  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,  60,  61,  62,  63,
  134.  64,  65,  66,  67,  68,  69,  70,  71,  72,  73,  74,  75,  76,  77,  78,  79,
  135.  80,  81,  82,  83,  84,  85,  86,  87,  88,  89,  90,  91,  92,  93,  94,  95,
  136.  96,  97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
  137. 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
  138. 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
  139. 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
  140. 255, 240,  63,  63, 242,  83,  73,  79,  74,  63,  63,  72,  75,  45, 246,  63,
  141. 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
  142. 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
  143. 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
  144. 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
  145. 252, 241,  63,  63, 243, 115, 105, 245, 106,  63,  63, 104, 107,  21, 247,  63
  146. };
  147.  
  148.  
  149. /*
  150.  * Translation table to map IBM Code Page 437 to Latin1
  151.  *
  152.  * The comments from textps.c read:
  153.  *
  154.  *  Line- and box-drawing characters are simulated with
  155.  *  dashes, bars, and plus signs.  Black and gray blobs (fill characters)
  156.  *  are replaced by X's.  Peseta is shown as P.  Greek letters that don't
  157.  *  exist in CourierLatin1 are shown as ?.  Untranslatable math symbols are
  158.  *  shown as ?.
  159.  */
  160. unsigned char cp437L1[] = {
  161.   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,
  162.  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,
  163.  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,  45,  46,  47,
  164.  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,  60,  61,  62,  63,
  165.  64,  65,  66,  67,  68,  69,  70,  71,  72,  73,  74,  75,  76,  77,  78,  79,
  166.  80,  81,  82,  83,  84,  85,  86,  87,  88,  89,  90,  91,  92,  93,  94,  95,
  167.  96,  97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
  168. 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
  169. 199, 252, 233, 226, 228, 224, 229, 231, 234, 235, 232, 239, 238, 236, 196, 197,
  170. 201, 230, 198, 244, 246, 242, 251, 249, 255, 214, 220, 162, 163, 165,  80, 151,
  171. 225, 237, 243, 250, 241, 209, 170, 186, 191,  43, 172, 189, 188, 161, 171, 187,
  172.  88,  88,  88, 124,  43,  43,  43,  43,  43,  43, 124,  43,  43,  43,  43,  43,
  173.  43,  43,  43,  43,  45,  43,  43,  43,  43,  43,  43,  43,  43,  45,  43,  43,
  174.  43,  43,  43,  43,  43,  43,  43,  43,  43,  43,  43,  88,  88,  88,  88,  88,
  175.  63, 223,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,
  176.  63, 177,  63,  63,  63,  63,  63,  63, 176, 134, 135,  63, 110, 178,  88, 160
  177. };
  178.  
  179.  
  180. /*
  181.  * Translation table to convert IBM CODE PAGE 850 to Latin1
  182.  *
  183.  * The comments from textps.c read:
  184.  *
  185.  *  IBM Code Page 850.  Line- and box-drawing characters are simulated with 
  186.  *  dashes, bars, and plus signs.  Black blobs are replaced by X's.
  187.  */
  188. unsigned char cp850L1[] = {
  189.   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,
  190.  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,
  191.  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,  45,  46,  47,
  192.  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,  60,  61,  62,  63,
  193.  64,  65,  66,  67,  68,  69,  70,  71,  72,  73,  74,  75,  76,  77,  78,  79,
  194.  80,  81,  82,  83,  84,  85,  86,  87,  88,  89,  90,  91,  92,  93,  94,  95,
  195.  96,  97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
  196. 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
  197. 199, 252, 233, 226, 228, 224, 229, 231, 234, 235, 232, 239, 238, 236, 196, 197,
  198. 201, 230, 198, 244, 246, 242, 251, 249, 255, 214, 220, 248, 163, 216, 215, 151,
  199. 225, 237, 243, 250, 241, 209, 170, 186, 191, 174, 172, 189, 188, 161, 171, 187,
  200.  88,  88,  88, 124,  43, 193, 194, 192, 169,  43, 124,  43,  43, 162, 165,  43,
  201.  43,  43,  43,  43,  45,  43, 227, 195,  43,  43,  43,  43,  43,  45,  43, 164,
  202. 240, 208, 202, 203, 200, 154, 205, 206, 207,  43,  43,  88,  88, 166, 204,  88,
  203. 211, 223, 212, 210, 245, 213, 181, 254, 222, 218, 219, 217, 253, 221, 175, 180,
  204. 173, 177,  61, 190, 182, 167, 247, 184, 176, 168, 134, 185, 179, 178,  88, 160
  205. };
  206.  
  207.  
  208. /*
  209.  * Map from ISO 8859-1 Latin-1 to Code Page 860
  210.  */
  211. unsigned char cp860L1[] = {
  212.   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,
  213.  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,
  214.  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,  45,  46,  47,
  215.  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,  60,  61,  62,  63,
  216.  64,  65,  66,  67,  68,  69,  70,  71,  72,  73,  74,  75,  76,  77,  78,  79,
  217.  80,  81,  82,  83,  84,  85,  86,  87,  88,  89,  90,  91,  92,  93,  94,  95,
  218.  96,  97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
  219. 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
  220. 199, 252, 233, 226, 227, 224, 193, 231, 234, 202, 232, 204, 212, 236, 195, 194,
  221. 201, 192, 200, 244, 245, 242, 218, 249, 205, 213, 220, 162,  63, 217,  63, 21,
  222. 225, 237, 243, 250, 241, 209, 170, 186, 191, 210, 172, 189, 188, 161, 171, 187,
  223.  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,
  224.  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,
  225.  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,
  226.  63, 223,  63,  63,  63,  63, 181,  63,  63,  63,  63,  63,  63, 248,  63,  63,
  227.  63, 177,  63,  63,  63,  63, 247,  63, 176, 183, 183,  63,  63, 178,  63,  63 
  228. };
  229.  
  230.  
  231. /*
  232.  * Map from ISO 8859-1 Latin-1 to Code Page 863
  233.  */
  234. unsigned char cp863L1[] = {
  235.   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,
  236.  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,
  237.  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,  45,  46,  47,
  238.  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,  60,  61,  62,  63,
  239.  64,  65,  66,  67,  68,  69,  70,  71,  72,  73,  74,  75,  76,  77,  78,  79,
  240.  80,  81,  82,  83,  84,  85,  86,  87,  88,  89,  90,  91,  92,  93,  94,  95,
  241.  96,  97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
  242. 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
  243. 199, 252, 233, 226, 194, 224, 182, 231, 234, 235, 232, 239, 238,  61, 192, 167,
  244. 201, 200, 202, 244, 203, 207, 251, 249, 164, 212, 220, 162,  63, 217, 219,  63,
  245. 166, 180, 243, 250, 168, 184, 179, 175, 206,  63, 172, 189, 188, 190, 171, 187,
  246.  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,
  247.  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,
  248.  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,
  249.  63, 223,  63,  63,  63,  63, 181,  63,  63,  63,  63,  63,  63, 248,  63,  63,
  250.  63, 177,  63,  63,  63,  63, 247,  63, 176, 183, 183,  63,  63, 178,  63,  63
  251. };
  252.  
  253.  
  254. /*
  255.  * Map from ISO 8859-1 Latin-1 to Code Page 865
  256.  */
  257. unsigned char cp865L1[] = {
  258.   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,
  259.  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,
  260.  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,  45,  46,  47,
  261.  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,  60,  61,  62,  63,
  262.  64,  65,  66,  67,  68,  69,  70,  71,  72,  73,  74,  75,  76,  77,  78,  79,
  263.  80,  81,  82,  83,  84,  85,  86,  87,  88,  89,  90,  91,  92,  93,  94,  95,
  264.  96,  97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
  265. 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
  266. 199, 252, 233, 226, 228, 224, 229, 231, 234, 235, 232, 239, 238, 236, 196, 197,
  267. 201, 230, 198, 244, 246, 242, 251, 249, 255, 214, 220, 248,  63, 216,  63,  63,
  268. 226, 237, 243, 250, 241, 209, 170, 186, 191,  63, 172, 189, 188, 161, 171, 164,
  269.  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,
  270.  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,
  271.  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,
  272.  63, 223,  63,  63,  63,  63, 181,  63,  63,  63,  63,  63,  63, 248,  63,  63,
  273.  63, 177,  63,  63,  63,  63, 247,  63, 176, 183, 183,  63,  63, 178,  63,  63
  274. };
  275.  
  276.  
  277. /*
  278.  * Map from ISO 8859-1 Latin-5 to Code Page 866
  279.  */
  280. unsigned char cp866L5[] = {
  281.   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,
  282.  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,
  283.  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,  45,  46,  47,
  284.  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,  60,  61,  62,  63,
  285.  64,  65,  66,  67,  68,  69,  70,  71,  72,  73,  74,  75,  76,  77,  78,  79,
  286.  80,  81,  82,  83,  84,  85,  86,  87,  88,  89,  90,  91,  92,  93,  94,  95,
  287.  96,  97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
  288. 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
  289. 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
  290. 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
  291. 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
  292.  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,
  293.  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,
  294.  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,
  295. 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
  296. 161, 241, 164, 244, 167, 247, 174, 254,  63,  63,  63,  63, 240,  63,  63, 160
  297. };
  298. #endif
  299.  
  300. /*----------------------------------------------------------------------
  301.     Return the specified file's contents in a translation array
  302.  
  303.   Args: file name to open
  304.  
  305.   Result: Returns array of unsigned char
  306.  
  307.   ----------------------------------------------------------------------*/
  308. unsigned char *
  309. read_xtable(fname)
  310.     char *fname;
  311. {
  312.     FILE *fp;
  313.     unsigned char *cp;
  314.     int  c, i = 0;
  315.  
  316.     if(fname && (fp = fopen(fname, "r"))){
  317.     cp = (unsigned char *)fs_get(256 * sizeof(unsigned char));
  318.  
  319.     while(fscanf(fp, "%d ", &c) == 1 && i < 256)
  320.       cp[i++] = (unsigned char)c;
  321.  
  322.     fclose(fp);
  323.  
  324.     if(i != 256){        /* table MUST be correct size */
  325.         q_status_message1(SM_ORDER,2,2,"Translation table \"%s\" too small",
  326.                   fname);
  327.         display_message('x');
  328.         fs_give((void **)&cp);
  329.     }
  330.  
  331.     return(cp);
  332.     }
  333.     else
  334.       return(NULL);
  335. }
  336.  
  337.  
  338. #ifndef OS2
  339. /*----------------------------------------------------------------------
  340.     Return the DOS version number
  341.  
  342.   Args: none.
  343.  
  344.   Result: Returns long containing major version in low-order byte, 
  345.       and the minor version in the high-order byte.
  346.  
  347.   ----------------------------------------------------------------------*/
  348. unsigned int
  349. dos_version()
  350. {
  351.     union REGS rg;
  352.  
  353.     rg.x.ax = 0x3000;            /* Have DOS report version num  */
  354.     intdos(&rg, &rg);
  355.     return(rg.x.ax);
  356. }
  357. #endif
  358.  
  359.  
  360. /*----------------------------------------------------------------------
  361.     Return the active Global Code Page value
  362.  
  363.   Args: none.
  364.  
  365.   Result: Returns integer value corresponding to active code page
  366.  
  367.   ----------------------------------------------------------------------*/
  368. int
  369. dos_codepage()
  370. {
  371. #ifdef OS2
  372.    ULONG cpList[16];
  373.    ULONG cpLen = sizeof cpList;
  374.    DosQueryCp(cpLen, cpList, &cpLen);
  375.    return (int)cpList[0];
  376. #else
  377.    union REGS rg;
  378.  
  379.    rg.h.ah = 0x66;        /* DOS int function to get/set code page */
  380.    rg.h.al = 0x01;        /* sub-function to get code page */
  381.    intdos(&rg, &rg);
  382.    return(rg.x.bx);        /* returned in bx */
  383. #endif
  384. }
  385.  
  386.  
  387.  
  388. /*----------------------------------------------------------------------
  389.     Read whole file into memory in binary mode
  390.  
  391.   Args: filename -- path name of file to read
  392.  
  393.   Result: Returns pointer to malloced memory with the contents of the file
  394.           or NULL
  395.  
  396. This won't work very well if the file has NULLs in it and is mostly
  397. intended for fairly small text files.
  398.   ----------------------------------------------------------------------*/
  399. char *
  400. read_binary_file(filename)
  401.      char *filename;
  402. {
  403.     int         fd;
  404.     struct stat statbuf;
  405.     char       *buf;
  406.     int        nb;
  407.  
  408.     fd = open(filename, O_RDONLY|O_BINARY);
  409.     if(fd < 0)
  410.       return(NULL);
  411.  
  412.     fstat(fd, &statbuf);
  413.  
  414.     buf = fs_get((size_t)statbuf.st_size + 1);
  415.  
  416.     if((nb=read(fd, buf, (unsigned)statbuf.st_size)) <= 0) {
  417.         close(fd);
  418.     fs_give((void **)&buf);
  419.         return(NULL);
  420.     }
  421.     close(fd);
  422.  
  423.     buf[nb]= '\0';
  424.  
  425.     return(buf);
  426. }
  427.  
  428.  
  429. /*
  430.  * fs_zero - null out n bytes of the pointed to memory
  431.  */
  432. fs_zero(p, n)
  433. void *p;
  434. long n;
  435. {
  436.     memset(p, 0, (size_t)n);
  437. }
  438.  
  439.  
  440. /*
  441.  * map the ftruncate call into DOS' chsize
  442.  */
  443. int
  444. ftruncate(fd, size)
  445.     int     fd;
  446.     long size;
  447. {
  448.     return(chsize(fd, size));
  449. }
  450.  
  451.  
  452. #ifndef OS2
  453. /*
  454.  * have_ printer - use BIOS int 0x17 to get a system equipment list
  455.  *           returning whether or not there's a printer
  456.  */
  457. have_printer()
  458. {
  459.     union REGS rg;
  460.  
  461.     int86(0x11, &rg, &rg);        /* what's there ? */
  462.     return(rg.x.ax & 0xc000);        /* any printers ? */
  463. }
  464.  
  465.  
  466. /*
  467.  * printer_status - get printer status using BIOS printer services (int 17h)
  468.  *             return 0 if printer responds bad status otherwise.
  469.  */
  470. unsigned short printer_ready()
  471. {
  472.     union REGS rg;
  473.  
  474.     if(!have_printer())            /* bother to get stat ? */
  475.       return(0xffff);
  476.  
  477.     rg.h.ah = 0x02;            /* get printer status */
  478.     rg.x.dx = 0;            /* which printer */
  479.     int86(0x17, &rg, &rg);        /* do it */
  480.  
  481.     return(rg.h.ah & ~(0xd6));        /* 0x10, 0x40 & 0x80 are OK */
  482.                     /* 0x02 and 0x04 are ignored */
  483. }
  484.  
  485.  
  486. /*
  487.  * p_printer_error - given a a byte of error code, return the string
  488.  *                   corresponding to it.
  489.  */
  490. char *p_printer_error(err)
  491. unsigned short err;
  492. {
  493.     if(err == 0xffff)
  494.     return("No printer found");
  495.     else if(err & 0x01)
  496.     return("Status 1: Time out (on line?)");
  497.     else if(err & 0x08)
  498.     return("Status 8: I/O error");
  499.     else if(err & 0x20)
  500.     return("Status 32: Out of paper ");
  501.     else if(err & 0x40 || err & 0x80 || err & 0x10)
  502.     /* ACK from printer or printer NOT busy or printer selected */
  503.     return("");
  504.     else
  505.         return("Weird printer status");
  506. }
  507.  
  508.  
  509. /*
  510.  * send_printer - write a byte to the printer returning status 
  511.  */
  512. int send_printer(c)
  513. char c;
  514. {
  515.     union REGS rg;
  516.  
  517.     rg.h.ah = 0;            /* service 0: send a byte */
  518.     rg.h.al = c;            /* which byte */
  519.     rg.x.dx = 0;            /* which printer */
  520.     int86(0x17, &rg, &rg);        /* do it */
  521.     return(rg.h.ah & ~(0xd6));        /* 0x10, 0x40 & 0x80 are OK */
  522.                     /* 0x02 and 0x04 are ignored */
  523. }
  524.  
  525.  
  526. /*
  527.  * coreleft - returns the amount of core memory currently available
  528.  */
  529. long
  530. coreleft()
  531. {
  532. #ifdef _WINDOWS
  533.     return (GetFreeSpace (0));
  534. #else
  535.     long ramfree = 0L;
  536.     register int i = 0, j;
  537.     static unsigned segs[10];
  538.     union  REGS r;
  539.     struct SREGS s;
  540.  
  541.     while(1){
  542.         r.h.ah = 0x48;            /* DOS alloc a paragraph */
  543.         r.x.bx = 0x0001;        /* grab 1 paragraph (16 bytes) */
  544.         intdos(&r, &r);
  545.         if(r.x.cflag){            /* carry flag set, no more core */
  546.         for(j=0;j<i;j++){
  547.                 r.h.ah = 0x49;        /* DOS free alloc'd core */
  548.                 s.es = segs[j];        /* segment to free */
  549.                 intdosx(&r, &r, &s);
  550.         }
  551.         return(ramfree*16L);
  552.         }
  553.     else
  554.             segs[i] = r.x.ax;        /* remember the sigment */
  555.  
  556.         r.h.ah = 0x4a;            /* DOS resize alloc'd core */
  557.         r.x.bx = 0xffff;        /* grab the biggest we can */
  558.         s.es = segs[i];            /* segment to resize */
  559.         intdosx(&r, &r, &s);
  560.  
  561.     if(r.x.cflag){
  562.             r.h.ah = 0x4a;            /* DOS resize alloc'd core */
  563.             s.es = segs[i];            /* segment to resize */
  564.             intdosx(&r, &r, &s);
  565.         ramfree += r.x.bx;
  566.     }
  567.         else
  568.         ramfree += 0xffff;
  569.  
  570.         i++;
  571.     }
  572. #endif
  573. }
  574. #endif
  575.  
  576. /*
  577.  * OS unique c-client calls and such.
  578.  */
  579.  
  580.  
  581. /*
  582.  * zone_offset - print the time zone offset in local differential
  583.  *               form : hours+minutes (HHMM)
  584.  */
  585. void
  586. zone_offset(buf)
  587. char *buf;
  588. {
  589.     struct timeb tb;
  590.  
  591.     ftime(&tb);
  592.     sprintf(buf, "%02.2u%02.2u", tb.timezone/60, tb.timezone%60);
  593. }
  594.  
  595.  
  596. #ifndef OS2
  597. /*
  598.  * Special hook so externally we can avoid copying from one file to
  599.  * another.  It's quite a hack, and not exactly clear, but does help
  600.  * performance-wise.
  601.  */
  602. FILE *append_file = NULL;
  603.  
  604. /*
  605.  * dos_gets - c-client callback for mail_fetchbody to use when receiving 
  606.  *            a message text too large for free mem (see mailview.c).
  607.  */
  608. char *dos_gets (f, stream, size)
  609. readfn_t  f;
  610. void     *stream;
  611. unsigned long      size;
  612. {
  613.     char tmp[MAILTMPLEN+1];
  614.     unsigned long j = 0L;
  615.     extern unsigned long gets_bytes;
  616.  
  617.     if(!append_file){
  618.     char es[128];
  619.     /* post error message, dump the text in the bit bucket */
  620.     mm_log("dos_gets: NO FILE HANDLE TO APPEND",ERROR);
  621.     return(NULL);
  622.     }
  623.  
  624.     while(size -= j){
  625.     (*f) (stream, j = min ((long) MAILTMPLEN, size), tmp);
  626.     gets_bytes += j;
  627. #ifndef    _WINDOWS
  628.     win_multiplex();
  629. #endif
  630.     if(fwrite(tmp, sizeof(char), (size_t)j, append_file) != j){
  631.         /* problem writing temp file! bail gracefully */
  632.         sprintf(tmp,"Error getting message: %s", error_description(errno));
  633.         mm_log(tmp, ERROR);
  634.         return(NULL);
  635.         }
  636.     }
  637.  
  638.     return(cpystr("programmer botch: data on disk"));
  639. }
  640.  
  641.  
  642. /*
  643.  *                   ******* DOS Cache Manager *******
  644.  *
  645.  * Each mail stream has associated with it a cache of mail elements 
  646.  * ("elt" in c-client parlance).  This can get too ponderous slog around
  647.  * in the 640K *MAX* that DOS allows, so the idea is to manager some number
  648.  * of them in core and page the rest out to disk.  ALL CACHE ACCESS IN
  649.  * C-CLIENT MUST TO GO THRU THE mailcache() FUNCTION!!
  650.  *
  651.  */
  652.  
  653.  
  654. /*
  655.  * CacheBlock_SIZE: number of elt's cached in core at any one time
  656.  */
  657. #define    CB_SIZE    (20L)
  658.  
  659.  
  660. /*
  661.  * Meta cache structure.  Used by dos_cache to hold either short or long
  662.  * elt's and a flag reporting if the entry's been accessed/used or not.
  663.  */
  664. typedef struct metacache {
  665.     short        use;        /* cache slot in use flag */
  666.     union {
  667.     MESSAGECACHE    mc;
  668.     LONGCACHE    lc;
  669.     } cachel;                /* access to cache elements */
  670. } METACACHE;
  671.  
  672.  
  673. /*
  674.  * Master DOS cache structure.  Every mail stream gets one, and has it
  675.  * until it dies.  c-client worries about freeing this with a CH_INIT.
  676.  */
  677. typedef struct doscache {
  678.     FILE        *dcf;        /* DOS cache file pointer */
  679.     char        *name;        /* DOS cache file's name  */
  680.         long        cbase;        /* index of array in slot 1 of block */
  681.     METACACHE    mcb[CB_SIZE];    /* meta cache block */
  682. } DOSCACHE;
  683.  
  684.  
  685. /*
  686.  * dcreadb - dos cache read block; given a stream, read a new block
  687.  *         of cache entries into core.  Doscache's cbase field
  688.  *           describes where to start loading.
  689.  */
  690. void dcreadb(cache)
  691. DOSCACHE *cache;
  692. {
  693.     size_t n;
  694.     
  695.     if(fseek(cache->dcf, cache->cbase * sizeof(METACACHE), SEEK_SET))
  696.       fatal("ran off end of dos cache file in dcreadb");
  697.  
  698.     n = fread((void *)&cache->mcb[0],sizeof(METACACHE),
  699.         (size_t)CB_SIZE,cache->dcf);
  700.  
  701.     if(n != CB_SIZE)
  702.       fatal("Can't read cache block in from disk");
  703. }
  704.  
  705.  
  706. /*
  707.  * dcwriteb - dos cache write block; given a stream, write the current 
  708.  *            block of cache entries to disk.  Guaranteed write, or fatal.
  709.  */
  710. void dcwriteb(cache)
  711. DOSCACHE *cache;
  712. {
  713.     size_t n;
  714.  
  715.     if(fseek(cache->dcf, cache->cbase * sizeof(METACACHE), SEEK_SET))
  716.       fatal("ran off end of dos cache file in dcwriteb");
  717.  
  718.     n = fwrite(&cache->mcb[0], sizeof(METACACHE), (size_t)CB_SIZE, cache->dcf);
  719.  
  720.     if(n != CB_SIZE)
  721.       fatal("Can't write cache block to from disk");
  722. }
  723.  
  724.  
  725.  
  726. /*
  727.  * dchit - make sure metacache entry for msgno is in core, if not, 
  728.  *         write current block and read in new one that contains it.
  729.  */
  730. void dchit(cache, msgno)
  731. DOSCACHE *cache;
  732. long      msgno;
  733. {
  734.     long i = msgno - 1;            /* index of msgno's elt */
  735.     size_t n;
  736.  
  737.     if(msgno <= 0)
  738.       fatal("bogus msgno passed to dchit");
  739.  
  740.     if(i >= cache->cbase && i < cache->cbase + CB_SIZE)
  741.       return;                /* everything's okey dokey */
  742.  
  743.     dcwriteb(cache);            /* roll out the current block */
  744.  
  745.     cache->cbase = (i/CB_SIZE) * CB_SIZE;
  746.     dcreadb(cache);            /* roll in the new block */
  747. }
  748.  
  749.  
  750.  
  751. /*
  752.  * dcget - dos cache get; given a stream and a message number in it, 
  753.  *         return a pointer to the cache entry associated with it.
  754.  */
  755. METACACHE *dcget(stream, msgno)
  756. MAILSTREAM *stream;
  757. long        msgno;
  758. {
  759.     int i;
  760.     DOSCACHE *dc = (DOSCACHE *)stream->cache.c;
  761.  
  762.     dchit(dc, msgno);            /* correct block in core? */
  763.  
  764.     i = (int)((msgno-1)%CB_SIZE);    /* offset of entry in block */
  765.     if(!dc->mcb[i].use){        /* new cache entry! */
  766.     memset((void *)&dc->mcb[i], 0, sizeof(METACACHE));
  767.     dc->mcb[i].use = 1;        /* mark entry as accessed */
  768.     if(stream->scache){
  769.         dc->mcb[i].cachel.mc.lockcount = 1;
  770.         dc->mcb[i].cachel.mc.msgno = msgno;
  771.     }
  772.     else{
  773.         dc->mcb[i].cachel.lc.elt.lockcount = 1;
  774.         dc->mcb[i].cachel.lc.elt.msgno = msgno;
  775.         dc->mcb[i].cachel.lc.env = NULL;
  776.         dc->mcb[i].cachel.lc.body = NULL;
  777.     }
  778.     }
  779.  
  780.     return(&dc->mcb[i]);
  781. }
  782.  
  783.  
  784.  
  785. /*
  786.  * dos_cache - c-client callback used to manage cached elt's and 
  787.  *             envelopes. (see ../c-client/mail.c)
  788.  */
  789. void *dos_cache(stream, msgno, op)
  790. MAILSTREAM *stream;
  791. long        msgno;
  792. long        op;
  793. {
  794.     size_t n;
  795.     void *ret = NULL;
  796.     long i = msgno - 1;
  797.     unsigned long j = stream->cachesize;
  798.     METACACHE ctmp;
  799.     DOSCACHE  *dtmp = (DOSCACHE *)stream->cache.c;
  800.  
  801.     switch ((int) op) {            /* what function? */
  802.       case CH_INIT:            /* initialize cache */
  803.         if (stream->cachesize) {    /* flush old cache contents */
  804.         
  805.         /*
  806.          * WARNING: if lock counts are ever important, this will 
  807.          *          have to become a loop counting down the 
  808.          *          cachesize and calling something like 
  809.          *          mail_free_elt() for each one!
  810.          */
  811.         fclose(dtmp->dcf); /* should auto blast tmpfile */
  812.         if(dtmp->name){
  813.         unlink(dtmp->name);
  814.         free(dtmp->name);
  815.         dtmp->name = NULL;
  816.         }
  817.  
  818.         fs_give((void **)&stream->cache.c);
  819.         stream->cachesize = 0;
  820.         }
  821.         break;
  822.  
  823.       case CH_SIZE:            /* (re-)size the cache */
  824.         if (msgno > j) {        /* do nothing if size adequate */
  825.         /*
  826.          * TUNING POTENTIAL: the const 4 below could be tweeked
  827.          */
  828.         while(msgno > stream->cachesize)
  829.           stream->cachesize += (CB_SIZE * 4);
  830.  
  831.             if (stream->cache.c == NULL){
  832.         stream->cache.c = (void *)fs_get(sizeof(DOSCACHE));
  833.         memset(stream->cache.c, 0, sizeof(DOSCACHE));
  834.         dtmp = (DOSCACHE *)stream->cache.c;
  835.         if(!dtmp->name)
  836.           dtmp->name = temp_nam(NULL, "pi");
  837.  
  838.         /*
  839.          * Can't use tmpfile() as MSC's library call won't 
  840.          * observe TMP or TEMP env vars.  Wonders never cease.
  841.          */
  842.         if((dtmp->dcf = (void *)fopen(dtmp->name, "w+b")) == NULL){
  843.             sprintf(tmp_20k_buf,"Can't open DOS cache: %s",dtmp->name);
  844.             fatal(tmp_20k_buf);
  845.         }
  846.  
  847.         for(j = 0; j < stream->cachesize; j += CB_SIZE){
  848.             dtmp->cbase = j;
  849.             dcwriteb(dtmp);
  850.         }
  851.         dtmp->cbase = 0;
  852.         }
  853.         else{
  854.         /* init new entries */
  855.         fseek(dtmp->dcf, j * sizeof(METACACHE), SEEK_SET);
  856.         memset((void *)&ctmp, 0, sizeof(METACACHE));
  857.         for(;j < stream->cachesize; j++){
  858.             n = fwrite((void *)&ctmp,sizeof(METACACHE),1,dtmp->dcf);
  859.             if(n != 1L)
  860.               fatal("Cache init failed on fwrite");
  861.         }
  862.         }
  863.         }
  864.         break;
  865.  
  866.       case CH_ELT:            /* return elt */
  867.       case CH_MAKEELT:            /* short elt, make if necessary */
  868.       case CH_LELT:            /* return long elt */
  869.       case CH_MAKELELT:            /* long elt, make if necessary */
  870.     ret = (stream->scache) ? (void *) &dcget(stream, msgno)->cachel.mc
  871.                            : (void *) &dcget(stream, msgno)->cachel.lc;
  872.     break;
  873.  
  874.       case CH_FREE:            /* free (l)elt */
  875.     /* 
  876.      * SEE WARNING ABOVE! if we ever need lock counts
  877.      * this should call an appropriate mail_free_XXX-like 
  878.      * function.
  879.      */
  880.     dcget(stream, msgno)->use = 0;
  881.     break;
  882.  
  883.       case CH_EXPUNGE:            /* expunge cache slot */
  884.     {                /* slide down remainder of cache */
  885.         METACACHE *dc_copy=(METACACHE *)fs_get(sizeof(METACACHE));
  886.  
  887. /*
  888.  * OPTIMIZE: this could be made a little more efficient by using offset
  889.  *           into the current block in memory, and copying blocks of 
  890.  *           elt's at a time rather than individually.
  891.  */
  892.         for (i = msgno+1; i <= stream->nmsgs; ++i){
  893.         memcpy((void *)dc_copy,
  894.                (void *)dcget(stream, i),
  895.                sizeof(METACACHE));
  896.         if(stream->scache) 
  897.           dc_copy->cachel.mc.msgno = i - 1L;
  898.         else
  899.           dc_copy->cachel.lc.elt.msgno = i - 1L;
  900.  
  901.         memcpy((void *)dcget(stream, i-1),
  902.                (void *)dc_copy,
  903.                sizeof(METACACHE));
  904.         }
  905.  
  906.         fs_give((void **)&dc_copy);
  907.         memset((void *)dcget(stream, stream->nmsgs),
  908.            0, 
  909.            sizeof(METACACHE));
  910.     }
  911.  
  912.     break;
  913.  
  914.     default:
  915.       fatal ("Bad dos_cache op");
  916.       break;
  917.     }
  918.  
  919.     return ret;
  920. }
  921.  
  922.  
  923.  
  924. /*
  925.  * ***** FOR DEBUGGING *****
  926.  */
  927. void dumpmetacache(stream)
  928. MAILSTREAM *stream;
  929. {
  930.     FILE *fp;
  931.     long i;
  932.     size_t  n;
  933.     METACACHE ce;
  934.     DOSCACHE *dp = (DOSCACHE *)stream->cache.c;
  935.  
  936.     if((fp=fopen("\\tmp\\cache.out","a")) == NULL)
  937.     return;
  938.     if(!stream->cache.c){
  939.     fprintf(fp,"NO CACHE ASSOCIATED WITH STREAM!!!\n");
  940.     }
  941.     else{
  942.         fprintf(fp,"****** cache has %ld entries (%d element blocks)\n", 
  943.         stream->cachesize, CB_SIZE);
  944.     fprintf(fp,"Those in core are:\n");
  945.     for(i=0; i < CB_SIZE; i++){
  946.       fprintf(fp,"  %d) ", i+1);
  947.       if(!dp->mcb[i].use){
  948.          fprintf(fp,"EMPTY\n");
  949.       }
  950.       else{
  951.          fprintf(fp,"# %ld, lock = %d, size = %ld\n", 
  952.             dp->mcb[i].cachel.mc.msgno,
  953.             dp->mcb[i].cachel.mc.lockcount,
  954.             dp->mcb[i].cachel.mc.rfc822_size);
  955.       }
  956.     }
  957.  
  958.     fprintf(fp,"Those on disk are:\n");
  959.     fseek(dp->dcf, 0L, SEEK_SET);
  960.     for(i=0; i < stream->cachesize; i++){
  961.       fprintf(fp,"  %d) ", i+1);
  962.       n = fread(&ce, sizeof(METACACHE), 1, dp->dcf);
  963.       if(n != 1){
  964.          fprintf(fp,"PROBLEM READING ENTRY!!!\n");
  965.          break;
  966.       }
  967.       if(!ce.use){
  968.          fprintf(fp,"EMPTY\n");
  969.       }
  970.       else{
  971.          fprintf(fp,"# %ld, lock = %d, size = %ld\n", 
  972.             ce.cachel.mc.msgno,
  973.             ce.cachel.mc.lockcount,
  974.             ce.cachel.mc.rfc822_size);
  975.       }
  976.     }
  977.     }
  978.     fclose(fp);
  979. }
  980.  
  981.  
  982. #ifndef    _WINDOWS
  983. /*
  984.  *
  985.  */
  986. unsigned
  987. alarm(t)
  988.     unsigned t;
  989. {
  990. }
  991. #endif
  992. #endif
  993.